﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using ValidationFramework.Reflection;
using System.Reflection;

namespace ValidationFramework.Web.MVC.Tests
{
	[TestFixture]
	public class TypeExtractionStrategyTest
	{
		[TestFixture]
		public class ShouldIncludeRulesFor
		{
			[Test]
			public void Should_Only_Return_True_If_Property_Is_In_WhiteList()
			{
				var typePolicy = MockRepository.GenerateStub<TypePolicy>();
				var cachedReflection =  MockRepository.GenerateStub<ICachedReflectionInfo>();
				cachedReflection.Expect(x => x.Name).Return("TestMember");

				var strategy = new TypeExtractionStrategy(typePolicy);
				strategy.AddToWhiteList("TestMember");

				// Act
				var includeRule = strategy.ShouldIncludeRulesFor(cachedReflection.Name);

				//Assert
				Assert.IsTrue(includeRule);
			}
			[Test]
			public void Should_Return_False_If_Property_Is_In_BlackList()
			{
				var typePolicy = MockRepository.GenerateStub<TypePolicy>();
				var cachedReflection = MockRepository.GenerateStub<ICachedReflectionInfo>();
				cachedReflection.Expect(x => x.Name).Return("TestMember");

				var strategy = new TypeExtractionStrategy(typePolicy);
				strategy.AddToBlackList("TestMember");

				// Act
				var includeRule = strategy.ShouldIncludeRulesFor(cachedReflection.Name);

				//Assert
				Assert.IsFalse(includeRule);
			}
		}
	}
}
